<template>
  <el-container>
    <el-header >
          <h3 :title="title" style="text-align: center" > {{title}} </h3>
    </el-header>
    <el-main>
      <kt-table
        :height="650"
        :perms="perms"
        :data="data"
        :columns="tableLabel"
        :btName="btName"
        :attribute="attribute"
        :title="title"
        @findPage="findPage"
      />
<!--        -->

    </el-main>
  </el-container>
</template>

<script>
  import KtTable from '@/views/Core/KtTable3'
    export default {
        name: "MoreElement",
      components: {
        KtTable
      },
      props:{
        elementId: {
          type: String,
          default: ''
        },
        moreLhsxbFlag:false,
        moreHjxwbFlag:false,
        moreStwhbFlag:false,
        moreJkwhbFlag:false,
        moreHyxxbFlag:false,
        title:'',
        attribute:'',
        btName:'',
        perms:''
      },
      data(){
         return{
           tableLabel: [
             {label: '属性', width: '', prop: 'attribute'},
             {label: '单位', width: '', prop: 'util'},
             {label: '值', width: '', prop: 'value'},
             {label: '温度', width: '', prop: 'temperature'},
             {label: '压强', width: '', prop: 'pa'},
             {label: '实测/预测', width: '', prop: 'shiceyuce'},
             {label: '数据来源', width: '', prop: 'source'},
             {label: '备注', width: '', prop: 'remark'},
           ],
           findParams:{
             elementId:'',
             labelName:'',
             flag:''
           },
           data:[{}],
           pageRequest: {
             pageNumber: 1,
             pageSize: 7
           },
         }
      },
      mounted(){
        this.queryElement()
        if (this.title === '理化属性表') {
          this.tableLabel = [
            {label: '属性', width: '', prop: 'attribute'},
            {label: '单位', width: '', prop: 'util'},
            {label: '值', width: '', prop: 'value'},
            {label: '温度', width: '', prop: 'temperature'},
            {label: '压强', width: '', prop: 'pa'},
            {label: '实测/预测', width: '', prop: 'shiceyuce'},
            {label: '数据来源', width: '', prop: 'source'},
            {label: '备注', width: '', prop: 'remark'}
          ]
        } else if (this.title === '环境行为表') {
          this.tableLabel = [
            {label: '属性', width: '', prop: 'attribute'},
            {label: '介质', width: '', prop: 'medium'},
            {label: '单位', width: '', prop: 'unit'},
            {label: '值', width: '', prop: 'value'},
            {label: '试验时间', width: '', prop: 'time'},
            {label: '试验方法', width: '', prop: 'method'},
            {label: '实测/预测', width: '', prop: 'shiceyuce'},
            {label: '数据来源', width: '', prop: 'source'},
            {label: '备注', width: '', prop: 'remark'}
          ]
        } else if (this.title === '生态危害表') {
          this.tableLabel = [
            {label: '属性', width: '', prop: 'attribute'},
            {label: '实验种属', width: '', prop: 'species'},
            {label: '试验时间', width: '', prop: 'time'},
            {label: '效应类型', width: '', prop: 'type'},
            {label: '效应值单位', width: '', prop: 'unit'},
            {label: '效应值', width: '', prop: 'value'},
            {label: '试验方法', width: '', prop: 'method'},
            {label: '实测/预测', width: '', prop: 'shiceyuce'},
            {label: '数据来源', width: '', prop: 'source'},
            {label: '备注', width: '', prop: 'remark'}
          ]
        } else if (this.title === '健康危害表') {
          this.tableLabel = [
            {label: '属性', width: '', prop: 'attribute'},
            {label: '试验生物种属', width: '', prop: 'species'},
            {label: '试验时间', width: '', prop: 'time'},
            {label: '效应类型', width: '', prop: 'type'},
            {label: '效应值单位', width: '', prop: 'unit'},
            {label: '效应值', width: '', prop: 'value'},
            {label: '致癌性IARC分类', width: '', prop: 'zax'},
            {label: '试验方法', width: '', prop: 'method'},
            {label: '实测/预测', width: '', prop: 'shiceyuce'},
            {label: '数据来源', width: '', prop: 'source'},
            {label: '备注', width: '', prop: 'remark'}
          ]
        } else if (this.title === '行业信息表') {
          this.tableLabel = [
            {label: '参数', width: '', prop: 'attribute'},
            {label: '参数单位', width: '', prop: 'util'},
            {label: '值', width: '', prop: 'value'},
            {label: '时间', width: '', prop: 'time'},
            {label: '数据来源', width: '', prop: 'source'},
            {label: '备注', width: '', prop: 'remark'}
          ]
        }

      },
      methods:{
        queryElement:function () {
          this.findParams.elementId=this.elementId
          this.findParams.labelName=this.attribute
          this.findParams.flag = 1
          if(this.title==="理化属性表"){
            this.$api.addrecord.findByIdAndFlagInLhsxb(this.findParams).then(res => {
            this.data = res.data
          })
          }else if(this.title==="环境行为表"){
            this.$api.addrecord.findByIdAndFlagInHjxwb(this.findParams).then(res => {
              this.data = res.data
          })
          }else if(this.title==="生态危害表"){
            this.$api.addrecord.findByIdAndFlagInStwhb(this.findParams).then(res => {
              this.data = res.data
            })
          }else if(this.title==="健康危害表"){
            this.$api.addrecord.findByIdAndFlagInJkwhb(this.findParams).then(res => {
              this.data = res.data
            })
          }else {
            this.$api.addrecord.findByIdAndFlagInHyxxb(this.findParams).then(res => {
              this.data = res.data
            })}

        },
        findPage: function (data) {
          if (data !== null) {
            this.pageRequest = data.pageRequest
          }
          if(this.title==="理化属性表"){
            this.$api.addrecord.findByIdAndFlagInLhsxb(this.findParams).then(res => {
              this.data = res.data
            }).then(data != null ? data.callback : '')
          }else if(this.title==="环境行为表"){
            this.$api.addrecord.findByIdAndFlagInHjxwb(this.findParams).then(res => {
              this.data = res.data
            }).then(data != null ? data.callback : '')
          }else if(this.title==="生态危害表"){
            this.$api.addrecord.findByIdAndFlagInStwhb(this.findParams).then(res => {
              this.data = res.data
            }).then(data != null ? data.callback : '')
          }else if(this.title==="健康危害表"){
            this.$api.addrecord.findByIdAndFlagInJkwhb(this.findParams).then(res => {
              this.data = res.data
            }).then(data != null ? data.callback : '')
          }else {
            this.$api.addrecord.findByIdAndFlagInHyxxb(this.findParams).then(res => {
              this.data = res.data
            }).then(data != null ? data.callback : '')}


          // if(this.title==="理化属性表"){
          //   this.$api.addrecord.findByPageInLhsxb(this.pageRequest).then(res => {
          //     this.data = res.data
          //   }).then(data != null ? data.callback : '')}
          // else if(this.title==="环境行为表"){
          //   this.$api.addrecord.findByPageInHjxwb(this.pageRequest).then(res => {
          //     this.data = res.data
          //   }).then(data != null ? data.callback : '')
          // }else if(this.title==="生态危害表"){
          //   this.$api.addrecord.findByPageInStwhb(this.pageRequest).then(res => {
          //     this.data = res.data
          //   }).then(data != null ? data.callback : '')
          // }else if(this.title==="健康危害表"){
          //   this.$api.addrecord.findByPageInJkwhb(this.pageRequest).then(res => {
          //     this.data = res.data
          //   }).then(data != null ? data.callback : '')
          // }else {
          //   this.$api.addrecord.findByPageInHyxxb(this.pageRequest).then(res => {
          //     this.data = res.data
          //   }).then(data != null ? data.callback : '')}
          }

      }

    }
</script>

<style scoped>

</style>
